<template>

  <el-tree :data="menu" :props="defaultProps" @node-click="handleNodeClick">
              <span class="custom-tree-node" slot-scope="{ node, data }">
                      <span>{{ node.label }}</span>
              </span>
  </el-tree>

</template>


<script>
export default {
  data () {
    return {
      menu: [],
      defaultProps: {
        children: 'children',
        label: 'name',
      },
    }
  },
  methods: {
    handleNodeClick (data) {
      console.log(data)
      this.$emit('child-event',data);
    },

    getMenus () {
      this.$http({
        url: this.$http.adornUrl('/gulimailproduct/category/list/tree'),
        method: 'get',
      }).then(({data}) => {
        console.log('成功获取到数据。。', data.data)
        this.menu = data.data
      })
    },
  },
  created () {
    this.getMenus()
  },
}
</script>
